package com.syni.mdd.yhd.common.all.service.impl;

import com.syni.mdd.sjb.common.component.utils.common.utils.ResultMapHelper;
import com.syni.mdd.yhd.common.all.constants.ResultMsg;
import com.syni.mdd.yhd.common.all.dao.jpa.BmsUserOpinionDao;
import com.syni.mdd.yhd.common.all.dto.requestDto.userOpinion.OpinionReDto;
import com.syni.mdd.yhd.common.all.entity.BmsUserOpinion;
import com.syni.mdd.yhd.common.all.service.BmsUserOpinionService;
import com.syni.mdd.sjb.common.component.utils.common.utils.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.Map;

/**
 * @className
 * @description TOO
 * @Author cfx
 * @DATE 2019/4/9 12:04
 * @VERSION 1.0
 **/
@Service
public class BmsUserOpinionImpl extends BaseService<BmsUserOpinion, Integer> implements BmsUserOpinionService {

    @Autowired
    BmsUserOpinionDao bmsUserOpinionDao;

    @Override
    public BmsUserOpinionDao getBaseDao() {
        return bmsUserOpinionDao;
    }

    @Override
    public Map<String, Object> feedback(OpinionReDto opinionReDto) {
        BmsUserOpinion bmsUserOpinion = new BmsUserOpinion();
        BeanUtils.copyProperties(opinionReDto,bmsUserOpinion);
        bmsUserOpinion.setNewTime(new Date());
        if(opinionReDto.getUserId() != null) {
            bmsUserOpinion.setBmsUserId(Integer.parseInt(opinionReDto.getUserId()));
        }
        bmsUserOpinionDao.save(bmsUserOpinion);
        return ResultMapHelper.success(null, ResultMsg.HAND_SUCCESS);
    }
}
